package Leetcode;

import java.util.ArrayList;
import java.util.List;

public class Leetcode_27 {
        public static List<Integer> goodDaysToRobBank(int[] security, int time) {
            int n = security.length;
            int[] left = new int[n];
            int[] right = new int[n];
            for (int i = 1; i < n; i++) {
                if (security[i] <= security[i - 1]) {
                    left[i] = left[i - 1] + 1;
                }
                if (security[n - i - 1] <= security[n - i]) {
                    right[n - i - 1] = right[n - i] + 1;
                }
            }

            List<Integer> ans = new ArrayList<>();
            for (int i = time; i < n - time; i++) {
                if (left[i] >= time && right[i] >= time) {
                    ans.add(i);
                }
            }
            return ans;
        }
    public static void main(String[] arr){
        int[] security = {5,3,3,3,5,6,2};
        int time = 2;
        System.out.println(goodDaysToRobBank(security,time));
    }
}
